﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using Fulcrum.DispatcherProxies;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.DispatcherProxies
{
    [TestClass]
    public class DispatcherProxyGenerationDataContextTests
    {
        public DispatcherProxyGenerationDataContextTests()
        {
            // nothing
        }

        DispatcherProxyGenerationDataContext dataContext;
        DispatcherProxySettings settings;

        [TestInitialize]
        public void TestInitialize()
        {
            this.settings = new DispatcherProxySettings();

            this.settings.Company = "My Company";
            this.settings.Copyright = "My Copyright";
            this.settings.Namespace = "My.Namespace";

            var target = new DispatcherProxyTarget(typeof(MyDispatcherClass), null);
            this.dataContext = new DispatcherProxyGenerationDataContext(this.settings, target);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextCompany()
        {
            Assert.AreEqual("My Company", this.dataContext.Company);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextCopyright()
        {
            Assert.AreEqual("My Copyright", this.dataContext.Copyright);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextName()
        {
            Assert.AreEqual("Fulcrum.UnitTests.DispatcherProxies.MyDispatcherClass", this.dataContext.Name);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextNamespace()
        {
            Assert.AreEqual("My.Namespace", this.dataContext.Namespace);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextOutputFileName()
        {
            Assert.AreEqual("MyDispatcherClassProxy", this.dataContext.OutputFileName);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextOutputPath()
        {
            Assert.AreEqual("", this.dataContext.OutputPath);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextTargetType()
        {
            var target = new DispatcherProxyTarget(typeof(MyDispatcherClass), null);
            var localDataContext = new DispatcherProxyGenerationDataContext(this.settings, target);

            Assert.IsNotNull(localDataContext.TargetType);
            Assert.AreSame(target, localDataContext.TargetType);
        }

        [TestMethod]
        public void TestDispatcherProxyGenerationDataContextTemplateFileName()
        {
            Assert.AreEqual("DispatcherProxies.t4", this.dataContext.TemplateFileName);
        }

    }
}
